
//const data= require('../../../../lib/data')
class temperatureAndHumidity {
 
  static read(buffer) {
  /*
        Data data = new Data();
        data.area = reader.ReadByte();
        data.temperature = reader.ReadSInt16(true);
        Debug.Log(data.temperature);
        data.humidity = reader.ReadByte();

        Debug.Log(JsonUtility.ToJson(data));
        onRecevie?.Invoke(data);
  */
  
        let offset = 0;
        const data = {};
        data.area = buffer.readUInt8(offset);
        offset+= 1
        data.temperature = buffer.readUInt16BE(offset);
        offset+= 2
        data.humidity = buffer.readUInt8(offset);
        offset+= 1
         return data;
  /*
    let offset = 0;
    const count = buffer.readUInt16LE(offset);
    console.log("count" + count);
    offset += 2;
    const data = {};
    data.rooms = [];
    
    let stm = { "buffer":buffer,"offset": offset, "data":null};

    for(let i = 0; i< count; ++i){
        stm = this.readStatus(stm);
        data.rooms.push(stm.data);
        offset = stm.offset;
    }
 
    console.log(buffer);
   */

  }
  static type(){
    return "temperatureAndHumidity"
  }
  static command(){
    return Buffer.from([0xFC, 0xD4],"latin1").readInt16LE()
  }
}

module.exports = temperatureAndHumidity